package com.wangrui.controller;

import com.wangrui.entity.Order;
import com.wangrui.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@RestController
public class OrderController {
    @Autowired
    private OrderMapper orderMapper;

    @GetMapping("/addOrder")
    public Order addOrder(String orderNo, BigDecimal amount, Long userId){
        Order order = new Order();
        order.setUserId(userId);
        order.setOrderDate(LocalDateTime.now());
        order.setOrderNo(orderNo);
        order.setRemark("abc");
        order.setAmount(amount);
        orderMapper.insert(order);
        return order;
    }
}
